//
//  WANavigationController.m
//
//  WoW Atlas, a World of Warcraft instance map, loot, and achievement browser.
//  Copyright 2010 Steven Mattera <stevenmattera@gmail.com>
//
//	Special Thanks to Dan Gilbert and the Atlas/Atlasloot Team.
//
//	WoW Atlas is free software; you can redistribute it and/or modify
//	it under the terms of the GNU General Public License as published by
//	the Free Software Foundation; either version 2 of the License, or
//	(at your option) any later version.
//
//	WoW Atlas is distributed in the hope that it will be useful,
//	but WITHOUT ANY WARRENTY; without even the implied warrenty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//	GNU General Public License for more deails.
//
//	You should have received a copy of the GNU General Public License
//	along with WoW Atlas; if not, write to the Free Software
//	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//

#import "WANavigationController.h"

@implementation WANavigationController
@synthesize delegate = _delegate;

- (id)initWithRootViewController:(id)controller {
	if (self = [super init]) {
		[self.view setBackgroundColor:[UIColor blackColor]];
		
		_containerView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 44.0f, 320.0f, 416.0f)];
		[_containerView setBackgroundColor:[UIColor blackColor]];

		_navigationBar = [[WANavigationBar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 44.0f)];
		
		_navigationTransitionView = [[UIView alloc] initWithFrame:CGRectMake(320.0f, 44.0f, 320.0f, 416.0f)];
		[_navigationTransitionView setBackgroundColor:[UIColor blackColor]];
		
		[((UIViewController *)controller).view setBounds:CGRectMake(0.0f, 0.0f, 320.0f, 416.0f)];
		[((UIViewController *)controller).view setCenter:CGPointMake(160.0f, 208.0f)];
		
		_viewControllers = [[NSMutableArray alloc] init];
		[_viewControllers addObject:controller];
		
		[_containerView addSubview:((UIViewController *)controller).view];
		[self.view addSubview:_containerView];
		[self.view addSubview:_navigationTransitionView];
		[self.view addSubview:_navigationBar];
	}
	
	return self;
}

- (void)dealloc {
	[_containerView release];
	_containerView = nil;
	
	[_navigationBar release];
	_navigationBar = nil;
	
	[_navigationTransitionView release];
	_navigationBar = nil;
	
	[_viewControllers release];
	_viewControllers = nil;
	
	if (_disappearingViewController != nil) {
		[_disappearingViewController release];
		_disappearingViewController = nil;
	}
	
	if (_delegate != nil) {
		[_delegate release];
		_delegate = nil;
	}
	
	[super dealloc];
}

#pragma mark ----
#pragma mark ==== Public Methods ====
#pragma mark ----

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
	
}

- (void)popViewControllerAnimated:(BOOL)animated {
	
}

- (void)popToViewController:(UIViewController *)viewController animated:(BOOL)animated {
	
}

- (void)popToRootViewControllerAnimated:(BOOL)animated {
	
}

- (UIViewController *)topViewController {
	return [_viewControllers lastObject];
}

- (UIViewController *)visibleViewController {
	return [(UIViewController *)[_viewControllers lastObject] modalViewController];
}

- (BOOL)navigationBarHidden {
	if (_navigationBar.frame.origin.y < 0.0f) return YES;
	
	return NO;
}

- (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated {
	
}

- (WANavigationBar *)navigationBar {
	return _navigationBar;
}


@end
